<template>
  <div class="main">
    <div class="det_top_box">
      <div class="detail_header">
        <div class="det_top">
          <div>使用部门：{{ form.OperateOrgName }}</div>
          <div>
            <img
              class="dep_top_img"
              src="@/assets/Images/AppIcon/icon_qr_code.png"
              alt=""
              @click="goQRCode"
            />
            <!--跳转拍照-->
            <eagle-uploader :after-read="afterRead">
              <!--跳转拍照-->
              <img
                class="dep_top_img"
                src="@/assets/Images/AppIcon/icon_pictures.png"
                alt=""
              />
            </eagle-uploader>
          </div>
        </div>
        <eagle-row class="det_name">{{ form.EquipmentName }}</eagle-row>
        <eagle-row class="det_location"></eagle-row>
        <eagle-row class="mb-10"> </eagle-row>
        <eagle-row class="mb-10">
          <eagle-col span="12">
            <span class="mr-5">修改人</span>
            <span>{{ form.EditChnName }}</span>
          </eagle-col>
          <eagle-col span="12">
            <span class="mr-5">修改时间</span>
            <span>{{ getFillterDate(form.EditDate) }}</span>
          </eagle-col>
        </eagle-row>
      </div>
    </div>
    <div class="det_tab">
      <div class="det_tab_item">
        <eagle-tag type="primary" size="large" mark>基本信息</eagle-tag>
        <eagle-cell-group :border="border">
          <eagle-cell title="设备类型" :value="form.EquipmentTypeName" />
          <eagle-cell title="设备编号" :value="form.EquipmentNo" />
          <eagle-cell title="规格型号" :value="form.SpecificationType" />
          <eagle-cell title="安装/使用位置" :value="form.Location || '无'" />
          <eagle-cell title="设备代码" :value="form.EquipmentWord" />
          <eagle-cell title="设备状态" :value="form.EquStatusName" />
          <eagle-cell title="设备管理人" :value="form.EquManagerChnName" />
          <eagle-cell title="使用部门" :value="form.OperateOrgName" />
          <eagle-cell
            title="购置/生产日期"
            :value="getFillterDate(form.BuyDay) || '无'"
          />
          <eagle-cell
            title="注册登记日期"
            :value="getFillterDate(form.RegisterDay) || '无'"
          />
          <eagle-cell
            title="使用登记证编号"
            :value="form.EquRegistrationWord"
          />
          <eagle-cell
            title="停用/报废日期"
            :value="getFillterDate(form.StopDay) || '无'"
          />
          <eagle-cell title="制造商" :value="form.MadeBusiness|| '无'" />
          <eagle-cell title="需要检验" :value="form.IsNeedCheck ? '是' : '否'" />
          <eagle-cell
          v-if="form.IsNeedCheck"
            title="最近检验日期"
            :value="getFillterDate(form.CheckDay)"
          />
          <eagle-cell
            v-if="form.IsNeedCheck"
            title="下次检验日期"
            :value="getFillterDate(form.NextCheckDay)"
          />
        </eagle-cell-group>
      </div>
      <div class="det_tab_item">
        <eagle-tag class="mb-10" type="primary" size="large" mark
          >实施检查</eagle-tag
        >
        <div class="det_tab_item_text">
          <div class="text_box">
            <div class="text_img">
              <div class="img_item" @click="_goDangerCheckTaskDetailEdit()">
                <img
                  src="@/assets/Images/AppIcon/icon_danger_main_checkplan.png"
                  alt=""
                />
                <div>发起检查</div>
              </div>
              <div class="img_item" @click="_goEquipmentRiskUnit()">
                <img
                  src="@/assets/Images/AppIcon/icon_danger_main_checktask.png"
                  alt=""
                />
                <div>检查表检查</div>
              </div>
              <div class="img_item" @click="_goEquEquipmentTask()">
                <img
                  src="@/assets/Images/AppIcon/icon_danger_main_checkdetail.png"
                  alt=""
                />
                <div>计划任务</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getDate } from "@/utils/getDate";
import { upload } from "@/api/common";

export default {
  components: {},
  data() {
    return {
      equipmentCode: this.$route.query.equipmentCode,
      recordId: this.$route.query.recordId,
      form: {},
      border: false,
    };
  },
  created() {
    this.geDetail();
  },
  methods: {
    getFillterDate(date) {
      return getDate(date);
    },
    geDetail() {
      let _this = this;
      let params = { equipmentCode: _this.equipmentCode };
      if (_this.recordId) {
        params = { id: _this.recordId };
      }
      _this.$axios.get("/EquEquipment/GetDetailEquipment",{params:params})
      .then((res)=>{
        _this.form = res.data;
      })
    },
    // 二维码
    goQRCode() {
      this.$router.push({
        path: "/Equipment/QRCode",
        query: {
         value:this.form.EquipmentName 
        },
      });
    },
    // 员工信息
    goStaffInfo() {
      this.$router.push("/Site_RiskUnit/StaffInfo");
    },
    // 检查记录
    goInspectRecord() {
      this.$router.push("/Site_RiskUnit/InspectRecord");
    },
    // 发起检查
    _goDangerCheckTaskDetailEdit() {
      // HiddenDangerArea
      this.$router.push({
        path: "/Danger/DangerCheckTaskDetailEdit",
        query: {
          areaCode: this.form.AreaCode,
          areaName: this.form.AreaName,
          areaType: this.form.AreaType,
          areaNo: this.form.AreaNo,
        },
      });
    },
    // 检查表检查 equipmentRiskUnit
    _goEquipmentRiskUnit() {
      this.$router.push({
        path: "/Equipment/equipmentRiskUnit",
        query: {
          equipmentCode: this.form.EquipmentCode,
        },
      });
    },
    // 检查任务 EquEquipmentTask
    _goEquEquipmentTask() {
      this.$router.push({
        path: "/Equipment/EquEquipmentTask",
        query: {
          checkAreaCode: this.form.EquipmentCode,
        },
      });
    },
    afterRead(file) {
      var me = this;
      let params = new FormData(); //创建form对象
      params.append("file", file.file);
      upload(params)
        .then((res) => {
          res.data.forEach((item) => {
            me.$router.push({
              name: "DangerCheckTaskDetailEdit",
              query: {
                originType: 3,
                areaCode: me.form.AreaCode,
                areaName: me.form.AreaName,
                areaType: me.form.AreaType,
                areaNo: me.form.AreaNo,
              },
              params: {
                file: item.FilePath,
              },
            });
          });
        })
        .catch((err) => {
          console.log("err", err);
        });
    },
  },
};
</script>

<style lang="less" scoped>
/*
        .main {
            height: 100vh;
        }
    */

.det_top_box {
  padding: 10px;
  background-color: #e8f1f8;
  height: auto;
}

.detail_header {
  color: #ffffff;
  background: url("../../../assets/Images/AppIcon/image_equipment_detail_bg.png");
  background-size: cover;
  padding: 10px;
  border-radius: 5px;
  /*background-color: #fff;*/

  .det_top {
    display: flex;
    justify-content: space-between;

    .dep_top_img {
      height: 18px;
      width: 18px;
      margin-right: 10px;
    }
  }

  .det_name {
    margin-top: 20px;
    text-align: center;
  }

  .det_location {
    text-align: center;
    margin-bottom: 20px;
  }
}
.det_tab {
  padding: 10px;
  .det_tab_item {
    padding: 10px 0;
    background-color: #fff;
    border-radius: 5px;
    margin-bottom: 10px;

    .det_tab_item_text {
      padding: 0 10px;
    }
  }
}

.text_box {
  padding: 10px;
  border-radius: 5px;
  background-color: #fff;
  margin-bottom: 10px;

  .text_top {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    .top_link {
      color: #1989fa;
    }
  }

  .text_item {
    display: flex;
    justify-content: space-between;
    margin-left: 10px;

    .item_link {
      color: #1989fa;
    }
  }

  .text_img {
    display: flex;
    align-items: center;

    .img_item {
      width: 33.3%;
      text-align: center;

      img {
        height: 25px;
        width: 25px;
        margin-bottom: 10px;
      }
    }
  }

  .text_history {
    display: flex;
    vertical-align: middle;
    margin-bottom: 10px;
  }

  .text_member {
    color: #1989fa;
    margin-bottom: 10px;
  }

  .text_total_img {
    display: flex;
    align-items: center;

    .img_item {
      width: 33.3%;
      text-align: center;

      .img_item_top {
        display: flex;
        vertical-align: middle;
        margin-bottom: 10px;
      }
      img {
        height: 15px;
        width: 15px;
        margin-right: 5px;
      }
    }
  }
  .text_record_list {
    .list_row {
      display: flex;
      justify-content: space-between;
      margin-bottom: 10px;
      > div {
        width: 33.3%;
      }
      .row_center {
        text-align: center;
      }
      .row_right {
        text-align: right;
      }
    }
  }
}
.operate_det {
  background-color: #fff;
  padding: 10px;
  .operate_list {
    border: 1px solid #e8f1f8;
    .operate_row_first {
      padding: 10px;
      background-color: #e8f1f8;
      border-bottom: 1px solid #e8f1f8;
      margin-bottom: 10px;
    }
    .operate_row {
      padding: 10px;
      border-bottom: 1px solid #e8f1f8;
      /*margin-bottom: 10px;*/
    }
  }
}
</style>
